package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.InvoiceRecords;
import com.drcoffee.drcoffeemall.entry.Result;
import com.drcoffee.drcoffeemall.service.InvoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/invoice")
public class InvoiceController {

    final
    InvoiceService invoiceService;

    public InvoiceController(InvoiceService invoiceService) {
        this.invoiceService = invoiceService;
    }


    /*
     * 申请开票
     * */
    @PostMapping("/applyForInvoice")
    public Result applyForInvoice(@RequestHeader String Token, @RequestBody InvoiceRecords invoiceRecords) {
        return invoiceService.applyForInvoice(Token, invoiceRecords);
    }

    /*
     * 获取上次开票信息
     * */
    @GetMapping("/getLastInvoice")
    public Result getLastInvoice(@RequestHeader String Token,@RequestParam String order_code) {
        return invoiceService.getLastInvoice(Token,order_code);
    }

    /*
     * 根据订单号获取发票OSS存储地址
     * */
    @GetMapping("/getInvoicePathByCode")
    public Result getInvoicePathByCode(@RequestParam String order_code) {
        return invoiceService.getInvoicePathByCode(order_code);
    }
}
